import ibm.cognos.imt.CogReport
import ibm.cognos.imt.DataItem
import ibm.cognos.imt.dataUsage.Categories
import ibm.cognos.imt.dataUsage.Measure
import ibm.cognos.imt.dataUsage.Slices
/**
 * Created with IntelliJ IDEA.
 * User: eric
 * Date: 4/22/14
 * Time: 3:39 PM
 * To change this template use File | Settings | File Templates.
 */
class MyReport extends CogReport {

//cognosServer= "http://9.110.94.115/ibmcognos/"
//    MyReport(modelpath){
//        modelPath = modelpath
//    }

    def revenue = dataItem("[Sales (query)].[Sales].[Revenue]").dataType(DataItem.DECIMAL)
    def revenueFact = dataItem("[Sales (query)].[Sales].[Revenue]") {
        dataUsage = 'fact'
        dataType = DataItem.DECIMAL
        aggregate = "average"
    }


    def country = dataItem("[Sales (query)].[Branch].[Country]").dataType(DataItem.STRING)
    def quantity = dataItem("[Sales (query)].[Sales].[Quantity]").dataType(DataItem.INTEGER)
    def grossProfit = dataItem("[Sales (query)].[Sales].[Gross profit]").dataType(DataItem.DECIMAL)
    def year = dataItem("[Sales (query)].[Time].[Year]").dataType(DataItem.INTEGER)
    def productLine = dataItem("[Sales (query)].[Products].[Product line]").dataType(DataItem.STRING)
//    def quantity = dataItem("[Sales (query)].[Sales].[Quantity]").dataType(1)

//    def filter1 = filter("[Revenue] > 50000000")
//    def filter2 = filter("[Country] includes ('China')")

//    def list1 = list([revenueFact, productLine, country]) { root->
////        root.style.CSS.@value = "x"
//        root.@name = "Eric"
//    }

//    def list1 = list(revenueFact, productLine, country).filter("[Revenue] > 1000000")
    def list2 = list([revenueFact])

    def barChart1 = combinationChart(revenue as Measure, year as Categories, productLine as Slices)

    def list3 = list([revenueFact, productLine, country] )
    def pie1 = pieChart(revenueFact as Measure, year as Categories, productLine as Slices)
//    def bubble1 = v2BubbleChart(quantity as BubbleMeasure, grossProfit as XAxisMeasure, revenue as YAxisMeasure, year as Categories, productLine as Series)

    def desc() {
//        table{
//            column(0)<< list1
//            column(1)<< list3
//        }
//
//        table(2,2){
//            cell(0,0)<<pie1
//            cell(1,1)<<barChart1
//        }

//        [list3, list1]
//        [list1, pie1, list3]
//        barChart1
        list2
    }

}

println(new MyReport()
        .modelPath("/content/folder[@name='Samples']/folder[@name='Models']/package[@name='GO Sales (query)']/model[@name='model']")
        .getSpec())


